<?php

require 'vendor/autoload.php';

use QL\QueryList;

// //采集某页面所有的图片
// $data = QueryList::get('http://cms.querylist.cc/bizhi/453.html')->find('img')->attrs('src');
// //打印结果
// print_r($data->all());


// boss职聘
class SpiderBoss
{
     protected $url = 'https://www.zhipin.com/job_detail/?query=Python&city=101010100&industry=&position='; 

     public function run()
     {
        $ql = QueryList::get($this->url,[],[
            'timeout' => 30,
            'headers' => [
                'cookie'=>'toUrl=/; JSESSIONID=""; __c=1586865390; lastCity=100010000; sid=sem_pz_bdpc_dasou_title; __g=sem_pz_bdpc_dasou_title; __l=r=https%253A%252F%252Fwww.zhipin.com%252Fuser%252Fsem7.html%253Fsid%253Dsem%2526qudao%253Dbdpc_baidu-pc-BOSS-JD02-B19KA02084%2526plan%253D%2525E5%252593%252581%2525E7%252589%25258C%2525E8%2525AF%25258D%2526unit%253D%2525E5%252593%252581%2525E7%252589%25258C-%2525E4%2525B8%25258B%2525E8%2525BD%2525BD%2526keyword%253Dboss%2525E4%2525B8%25258B%2525E8%2525BD%2525BD%2526bd_vid%253D8560152559053240233%2526csource%253Dboctb&l=%252Fjob_detail%252F%253Fka%253Dheader-job&g=%2Fwww.zhipin.com%2F%3Fsid%3Dsem_pz_bdpc_dasou_title&friend_source=0&friend_source=0; Hm_lvt_194df3105ad7148dcf2b98a91b5e727a=1586865387,1586865483; __a=27930042.1586865386.1586865386.1586865390.11.2.10.8; __zp_stoken__=b295xDk%2Ff7i%2FWCzDJ%2BEbITyj9liS4iBeKIncIxZZ9tn2VKeFvq%2FqUg8MRtTxsj4s%2BliD%2FrEW%2FiVLOuBMzbTd%2BRcw5i1kTvExVirvknLRL3vSvmvutZalImiN4tMhdJlsV66u; Hm_lpvt_194df3105ad7148dcf2b98a91b5e727a=1586866687; __zp_sseed__=HKae90jsTX6DrevZZ5kVfmzw7ckByGYyoCv7LdScQAE=; __zp_sname__=41aea8c9; __zp_sts__=1586866721505',
                'Referer' =>  $this->url,
                'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'
            ]]);
            $html = $ql->getHtml();
            $title = QueryList::html($html)->find('.boss-slide')->html();
            dump($title);
     }

}
$spider = new SpiderBoss();
$spider->run();

